package com.geor.gcv.core.mat;

import java.awt.Image;
import java.io.File;
import java.util.List;

import javax.imageio.ImageIO;

import org.opencv.core.Mat;

/**
 * 处理图像的抽象类
 * 
 * @author lusongnan
 *
 */
public abstract class ProcessImageAbstract implements ProcessImage {

	@Override
	public Image[] deal(String path) throws Exception {
		String strs[] = path.split("=");

		Image images[] = new Image[strs.length];

		for (int i = 0; i < strs.length; i++) {
			images[i] = ImageIO.read(new File(strs[i]));
		}

		return images;
	}

	@Override
	public Image[] deal(List<Mat> mats) throws Exception {
		Image images[] = new Image[mats.size()];

		for (int i = 0; i < mats.size(); i++) {
			Mat mat = mats.get(i);
			if (mat != null)
				images[i] = Mats.MatToImage(mat, ".png");
		}

		return images;
	}
}
